"""
   ┌─┐       ┌─┐ + +
┌──┘ ┴───────┘ ┴──┐++
│                 │
│       ───       │++ + + +
███████───███████ │+
│                 │+
│       ─┴─       │
│                 │
└───┐         ┌───┘
    │         │
    │         │   + +
    │         │
    │         └──────────────┐
    │                        │
    │                        ├─┐
    │                        ┌─┘
    │                        │
    └─┐  ┐  ┌───────┬──┐  ┌──┘  + + + +
      │ ─┤ ─┤       │ ─┤ ─┤
      └──┴──┘       └──┴──┘  + + + +
             神兽保佑
            代码无BUG!
"""
from wsgiref.simple_server import make_server


def application(environ, start_response):
    # environ 按http解析数据
    # start_response：按http解析数
    print(environ)
    start_response("200 OK", [])
    path = environ.get('PATH_INFO')
    print(path)
    if path == "/login":
        with open("login.html", "r") as f:
            data = f.read()
        return [data.encode("utf8")]
    else:
        with open("index.html", "r") as f:
            data = f.read()
        return [data.encode("utf8")]


httped = make_server("127.0.0.1", 9980, application)  # 封装socket

# 等待连接
httped.serve_forever()
